<?php
/**
 * 代理模式
 * This file is part of pattern.
 * Author: tangzhou
 * Date: 2016/9/2
 * Time: 15:10
 * File: proxy.php
 */

interface IGiveGift
{
    function giveRose();
    function giveChocolate();
}

class Follower implements IGiveGift
{
    private $girlName;

    function __construct($name)
    {
        $this->girlName = $name;
    }

    function giveRose()
    {
        echo "{$this->girlName}:这是我送你的玫瑰，望你能喜欢。<br/>";
    }

    function giveChocolate()
    {
        echo "{$this->girlName}:这是我送你的巧克力，望你能收下。<br/>";
    }

}

/**
 * 代理
 * Class Proxy
 */
class Proxy implements IGiveGift
{
    private $follower;

    function __construct($name = 'girl')
    {
        $this->follower = new Follower($name);
    }

    function giveChocolate()
    {
        $this->follower->giveChocolate();
    }

    function giveRose()
    {
        $this->follower->giveRose();
    }
}

$proxy=new Proxy('范冰冰');
$proxy->giveRose();
$proxy->giveChocolate();